import { createWebHashHistory, createRouter } from 'vue-router';
import HomeView from '@/view/home/index.vue';
import register from '@/view/register/index.vue';
import forget from '@/view/forget/index.vue';
import login from '@/view/login/index.vue';
import code from '@/view/login/code.vue';
import info from '@/view/info/index.vue';
import study from '@/view/study/index.vue';
import benefits from '@/view/benefits/index.vue';
import pms from '@/view/pms/index.vue';
import detail from '@/view/detail/index.vue';
import ai from '@/view/ai/index.vue';
import circle from '@/view/circle/index.vue';
export const constantRoutes = [
  {
    path: '/',
    redirect:'/home'
  },
  {
    path: '/home',
    name: 'home',
    component: HomeView
  },
  {
    path: '/register',
    name: 'register',
    component: register
  },
  {
    path: '/forget',
    name: 'forget',
    component: forget
  },
  {
    path: '/login',
    name: 'login',
    component: login
  },
  {
    path: '/code',
    name: 'code',
    component: code
  },
  {
    path: '/info',
    name: 'info',
    component: info
  },
  {
    path: '/study',
    name: 'study',
    component: study
  },
  {
    path: '/benefits', //会员权益
    name: 'benefits',
    component: benefits
  },
  {
    path: '/pms', //pms
    name: 'pms',
    component: pms
  },
  {
    path: '/detail', //资讯详情
    name: 'detail',
    component: detail
  },
  {
    path: '/ai', //ai
    name: 'ai',
    component: ai
  },
  {
    path: '/circle', //学友圈
    name: 'circle',
    component: circle
  },
]
const router = createRouter({
  history: createWebHashHistory(),
  routes: constantRoutes,
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return { top: 0 }
    }
  },
});

export default router;